/*
日期时间工具
 */

/*
根据出生日期计算年龄(yyyy-MM-dd)
 */
function getBrithAge(birthday) {
    var nowDay = new Date();
    //出生年月日
    var birthYear = birthday.getFullYear();
    var birthMonth = birthday.getMonth() + 1;
    var birthDate = birthday.getDate();
    //当前年月日
    var nowYear = nowDay.getFullYear();
    var nowMonth = nowDay.getMonth() + 1;
    var nowDate = nowDay.getDate();
    //计算年差
    var age = nowYear - birthYear;
    //当前月大于出生月，则岁数不足
    if (nowMonth < birthMonth) {
        age = age - 1;
    } else if (nowMonth == birthMonth) {
        if (nowDate < birthDate) {
            age = age - 1;
        }
    }
    return age;
}

/*
 获取addDayCount 天后的日期
  */
function getDateStr(addDayCount) {
    var dd = new Date();
    dd.setDate(dd.getDate() + addDayCount);//获取addDayCount天后的日期
    var y = dd.getFullYear();
    var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期，不足10补0
    var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号，不足10补0
    return y + "-" + m + "-" + d;
}